// 隐藏导航栏
$(function () {
    var cubuk_seviye = $(document).scrollTop();
    var header_yuksekligi = $("header").outerHeight();

    $(window).scroll(function () {
        var kaydirma_cubugu = $(document).scrollTop();

        if (kaydirma_cubugu > header_yuksekligi) {
            $("header").addClass("rolldown");
        } else {
            $("header").removeClass("rolldown");
        }

        if (kaydirma_cubugu > cubuk_seviye) {
            $("header").removeClass("rollup");
        } else {
            $("header").addClass("rollup");
        }

        cubuk_seviye = $(document).scrollTop();
    });
});
// 表格隔行
$(function () {
    $("tr:odd").css("background-color", "rgba(0, 0, 0, 0.4)");
    $("tr:even:gt(0)").css("background-color", "none");
});

//导航栏创建
const li1 = [{
        title: "装备",
        url: "../weapon/weapon_all.html",
        id: "id1",
        li2: [{
                title: "武器",
                href: "../weapon/weapon_all.html#weapon",
            },
            {
                title: "防具",
                href: "../weapon/weapon_all.html#eq",
            },
            {
                title: "戒指",
                href: "../weapon/weapon_all.html#ring",
            }
        ]
    },
    {
        title: "法术",
        url: "../magic/magic_all.html",
        id: "id2",
        li2: [{
                title: "魔法",
                href: "../magic/magic_all.html#magic_sorcery",
            },
            {
                title: "奇迹",
                href: "../magic/magic_all.html#magic_miracle",
            },
            {
                title: "咒术",
                href: "../magic/magic_all.html#magic_description",
            }
        ]
    },
    {
        title: "道具",
        url: "../error.html",
        id: "id3",
        li2: [{
                title: "消耗品",
                href: "../error.html",
            },
            {
                title: "贵重物品",
                href: "../error.html",
            },
            {
                title: "强化材料",
                href: "../error.html",
            },
            {
                title: "工具",
                href: "../error.html",
            },
            {
                title: "箭矢",
                href: "../error.html",
            }
        ]
    },
    {
        title: "知识",
        url: "../error.html",
        id: "id4",
        li2: [{
                title: "人物",
                href: "../error.html",
            },
            {
                title: "誓约",
                href: "../error.html",
            }
        ]
    },
]




var ul1 = $(".ul_main");

$(function () {
    for (let i in li1) {
        let li = $("<li></li>").addClass("li1");

        let a = $("<a></a>").text(li1[i].title);
        let span = $("<span></span>");
        let ul2 = $("<ul></ul>").addClass("ul2");

        a.attr("href", li1[i].url);

        li.attr("id", li1[i].id);

        ul1.append(li);
        li.append(span);
        span.append(a);
        li.append(ul2);
        for (let l in li1[i].li2) {
            let li2 = $("<li></li>");
            let a2 = $("<a></a>").text(li1[i].li2[l].title);

            a2.attr("href", li1[i].li2[l].href);

            ul2.append(li2);
            li2.append(a2);
        }

    }
});

// 菜单效果
$(function () {
    $(".li1").hover(function () {
            $(this).find("li").css({
                "opacity": "1",
                "height": "40px",
                "padding-top": "15px"
            })
        },
        function () {
            $(this).find("li").css({
                "opacity": "0",
                "height": "0px",
                "padding-top": "0px"
            })
        });
});

